<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'shopcat.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<style type="text/css">
		#main{
			width: 700px;
			margin: 0 auto;
		}
	</style>
  </head>
  
  <body>
    <div id="main">
    	<table border="1px">
    			<tr>
	    			<td colspan="4"><h1>下面，是<span style="color:blue">${sessionScope.user.name }</span>的购物车</h1></td>
	    		</tr>
    		<s:if test="orders!=null">
    			<tr>
    				<td colspan="4">
    					<form action="ordersAction!changeOrder" method="post">
    						<input type="hidden" name="changeOrder.id" value="${orders.id }">
    						<select name="changeOrder.address.id">
    							<s:iterator value="addresses">
    								<option value="${id}">${address}</option>
    							</s:iterator>
    						</select>
    						<input type="submit" value="确定下单">
    					</form>
    				</td>
    			</tr>
	    		<tr style="bgcolor:#FFCCFF">
	    			<td colspan="2">订单编号</td>
	    			<td colspan="2">订单总价</td>
	    		</tr>
	    		<tr style="bgcolor:#FFFFCC">
	    			<td>商品编号</td>
	    			<td>商品名称</td>
	    			<td>购买数量</td>
	    			<td>商品单价</td>
	    		</tr>
	    		<tr>
	    			<td colspan="2">${orders.id }</td>
	    			<td colspan="2">${sum}</td>
	    		</tr>
	   			<s:iterator value="orders.onps" var="o">
	   				<tr>
	   					<td>${o.product.id}</td>
	   					<td>
	   						<img src="img/${o.product.img}.jpg" width="100px"><br/>
	   						${o.product.name }
	   					</td>
	   					<td>${o.num}</td>
	   					<td>${o.product.price }</td>
	   				</tr>
	   			</s:iterator>
   			</s:if>
   			<s:if test="orders==null">
   				<tr>
   					<td colspan="4">
   						<h1>暂无数据</h1>
   					</td>
   				</tr>
   			</s:if>
    	</table>
    </div>
  </body>
</html>
